use Diversification.dta, clear

* reduced sample with the Theil decomposition
keep if reduced==1

* elimination of the microstates
egen mpop=mean(pop), by(reporter)
drop if mpop<1000000

* estimations

gen  GDPpcppp2= GDPpcppp* GDPpcppp
encode reporter, gen(id)

regress  Tred  GDPpcppp GDPpcppp2, robust
predict yT
regress  T_within GDPpcppp GDPpcppp2, robust
predict yTw
regress  T_between GDPpcppp GDPpcppp2, robust
predict yTb

sort GDPpcppp
drop if GDPpcppp>40000
replace yT=yT+0.16
gen z=2

* figure 2

label var yT "Total Theil Index"
twoway (rarea yT yTw GDPpcppp, sort lcolor(black) lpattern(solid) lwidth(medium) fcolor(gray)) (line yT GDPpcppp, sort lcolor(red) lpattern(solid) lwidth(thick))(rarea yTw z GDPpcppp, sort lcolor(black) lpattern(solid) lwidth(medium) fcolor(blue)), legend(off)
